<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class StateConfig extends Authenticatable
{
    use Notifiable;
	protected $table = 'state_config';


    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];

	// 根据关键字获取所有状态数组
	public static function getAllState($keyword){
		$states = DB::table('state_config')
			->where('keywords',trim($keyword))
			->select('state','stateName')
			->get()
			->toArray();
		if(!$states){
			return '';
		}
		return $states;
	}

    // 获取指定状态的name
	public static function getStateName($keyword,$state_id){
		$stateName = DB::table('state_config')
			->where('keywords',trim($keyword))
			->where('state',$state_id)
			->select('stateName')
			->get()
			->toArray();
		if(!$stateName){
			return '';
		}
		return $stateName[0]->stateName;
	}


}
